#pragma once
#include"Common.h"
#include"ObjectPool.h"
#include <unordered_map>
#include "PageMap.h"
class PageCache {

public:
	static PageCache* GetInstance() {
		return &_sInst;
	}
	Span* NewPage(size_t n_page);
	Span* MapObjectToSpan(void* obj);
	void ReleaseSpanToPage(Span* span);
	std::mutex pub_mutx;
	
private:
	RemainMemoryPool<Span> ObjectPool;
	//std::unordered_map<PAGE_ID, Span*> _idSPanMap;
	TCMalloc_PageMap1<32 - PAGE_SHIFT> _idSpanMap;
	SpanList _Page_freelist[NPAGES];
	static PageCache _sInst;
	PageCache() {
	};
	PageCache(const PageCache &) = delete;
};
